<?php


function dologin(){

    if($_POST['verify']==$_SESSION['verify']){
$username=$_POST['username'];
$password=md5($_POST['password']);
$sql="select * from admin where username='{$username}' and password='{$password}'";
$row=getRow($sql);

 if($row){
        var_dump($row);
        $_SESSION['adminname']=$row['username'];
        alertMsg('登陆成功','index.php');
    }else{
       alertMsg('登录失败','login.php');
    }

        //查询
    }else{
        alertMsg('验证码错误','login.php');
    }


}

function addAdmin(){
    $_POST['password']=md5($_POST['password']);
      if(insert('admin',$_POST)){
        alertMsg('添加管理成功','listAdmin.php');
      }else{
        alertMsg('添加失败','addAdmin');
      }

}

function editAdmin($id){
    $arr=$_POST;
    $arr['password']=md5($_POST['password']);
    if(update("admin",$arr,"id={$id}")){
        alertMsg('修改成功!','listAdmin.php');
    }else{

        alertMsg('修改失败!','listAdmin.php');
    }


}

function delAdmin($id){
    if(delete('admin',' id='.$id)>0){
        alertMsg('删除管理成功','listAdmin.php');

    }else{
       echo '删除失败'.mysql_error();

    }

}

function getAlladmin($page,$pagesize){
    $offset=($page-1)*$pagesize;
    $sql="select * from admin limit $offset,$pagesize";
    return fetchall($sql);
}

function checkLogin(){


}
function getTotalpage(){
  return getresnum('select * from admin');

}
//wo